Problem Note 50584: Syntax error is generated within PROC SQL when a query is inside a macro
Syntax errors occur when a PROC SQL query is embedded within a user-created macro function and the following conditions exist:
- A comment flows for more than two lines and is at least as long as the comment in the code.
Also, the comment does not extend to a third line.
- No blank line exists between the comment and the beginning of the SQL code.
- A macro variable, terminated with a period (.), is referenced on the WHERE clause and is compared to a
column with the < symbol. (The problem occurs with the > symbol, too, but not with: =, <=, >= or <>
symbols.)
- The terminating semicolon (;) must be on a separate line after the WHERE clause.
Here are four possible changes that prevent the error:
- Removing the period (.) after the macro variable referenced on the WHERE clause
- Moving the semicolon (;) that terminates the PROC SQL step to the same line as the WHERE clause
- Removing the blank line between the %MACRO declaration and the comment prior to the PROC SQL invocation
- Moving the comment out of the macro and putting the comment prior to the %MACRO declaration
Click the Hot Fix tab in this note to access the hot fix for this issue.
Operating System and Release Information
SAS System | N/A | Z64 | 9.3 TS1M2 | 9.4 TS1M1 |
z/OS | 9.3 TS1M2 | 9.4 TS1M1 |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
A syntax is generated from PROC SQL if within a macro and certain criteria are met.
Type: | Problem Note |
Priority: | medium |
Date Modified: | 2013-08-13 09:42:21 |
Date Created: | 2013-08-01 10:48:25 |